<?php
/***************************************************************************
 * 
 * Copyright (c) 2010 , Inc. All Rights Reserved
 * $Id$:MCTimerTest.php,2010/05/20 13:52:50 
 * 
 **************************************************************************/
 
 
 
/**
 * @file MCTimerTest.php
 * @author huqingping
 * @date 2010/05/20 13:52:50
 * @version 1.0 
 * @brief 
 *  
 **/

require_once 'PHPUnit/Framework/TestCase.php';
require_once dirname(__FILE__).'/../MCUtil.php';

class MCTimerTest extends PHPUnit_Framework_TestCase
{
	function testTimer()
	{
		$timer = MCUtil::load('MCTimer');
		$timer->begin('test1');
		sleep(1);
		$timer->begin('test2');
		sleep(1);
		$timer->end('test2');
		$timer->begin('test3','test4');
		sleep(1);
		$result = $timer->getResult(false);
		$this->assertEquals(1, count($result));
		$this->assertTrue($result[0][1]>1000000);

		$timer->end('test1','test3');
		$result = $timer->getResult(false);
		$this->assertEquals(3, count($result));
		$this->assertTrue($result[0][1]>3000000);
		$this->assertTrue($result[1][1]>1000000);
		$this->assertTrue($result[2][1]>1000000);

		$result = $timer->getResult(true);
		$this->assertEquals(4, count($result));
		$this->assertTrue($result[0][1]>3000000 && $result[3][1] < 4000000);
		$this->assertTrue($result[1][1]>1000000 && $result[1][1]<2000000);
		$this->assertTrue($result[2][1]>1000000 && $result[2][1]<2000000);
		$this->assertTrue($result[3][1]>1000000 && $result[3][1]<2000000);


	}

}






/* vim: set ts=4 sw=4 sts=4 tw=100 noet: */
?>
